---
title: Create a prompt
description: Learn how to create a prompt with Latitude SDK
---

## Code

Here is how you can get or create a new prompt with our SDK. If the prompt already exists, it will be returned. Otherwise, a new prompt will be created.

<Note>You can't create prompts on `live` versions. You have to create a new
version and point to it.</Note>

<CodeGroup>
````typescript Typescript
import { Latitude } from '@latitude-data/sdk'

const PROMPT = `
Answer succinctly yet complete.
<user>
  Tell me a joke about a {{topic}}
</user>
`
async function run() {
  const sdk = new Latitude(process.env.LATITUDE_API_KEY, {
    projectId: Number(process.env.PROJECT_ID),
    // YOU CAN NOT CREATE A PROMPT IN A LIVE Version
    // versionUuid='live',
    // More info: https://docs.latitude.so/guides/prompt-manager/version-control
    versionUuid: '[CREATE_A_NEW_VERSION_UUID]',
  })

  const response = await sdk.prompts.getOrCreate('create-prompt/example', {
    prompt: PROMPT,
  })
  console.log('Response', response)
}

run()
````
````python Python
import asyncio
import os

from latitude_sdk import (
    Latitude,
    LatitudeOptions,
    GetOrCreatePromptOptions,
)


PROMPT = """
Answer succinctly yet complete.
<user>
  Tell me a joke about a {{topic}}
</user>
"""


async def run():
    api_key = os.getenv("LATITUDE_API_KEY")
    sdk_options = LatitudeOptions(
        project_id=int(os.getenv("PROJECT_ID")),
        # YOU CAN NOT CREATE A PROMPT in A LIVE Version
        # version_uuid='live',
        # More info: https://docs.latitude.so/guides/prompt-manager/version-control
        version_uuid="[CREATE_A_NEW_VERSION_UUID]",
    )

    sdk = Latitude(api_key, sdk_options)

    result = await sdk.prompts.get_or_create(
        "create-propmpt/example",
        GetOrCreatePromptOptions(prompt=PROMPT),
    )
    print(result, "\n" * 2)


asyncio.run(run())
````
</CodeGroup>
